<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        body,html{
            height: 100%;
        }
        div{
            display: flex;left: 0;right:0;top: 0;bottom:0;margin: 100px auto;width: 300px;height: 300px;background-color: skyblue;line-height: 200px;
        }
        span{color: red;}

    </style>
</head>
<body>
    1.#2fdesg a-f 0-9 6个数
    <script>
        // function fn(){
        //     var str="0123456789abcdef";
        //     var color="#";
        //     for(var i=0;i<6;i++){
        //         var num=Math.floor(Math.random()*str.length)
        //         // console.log(num);
        //         // console.log(str[num]) 
        //         color=color+str[num]
        //     }
        //     console.log(color);
        // }
        // fn()
    </script>


    <div id="ads">
        <h3>广告,在<span id="count5s">5</span>秒钟之后关闭!!!</h3>
    </div>
     2.广告弹出.5秒后关闭
     <script>
        var oCount5s=document.getElementById('count5s').innerText;
        // console.log(oCount5s);
        var second=parseInt(oCount5s);
        // console.log(second);

        // 广告弹窗
        function closeAds(){
            document.getElementById('ads').style.display="none"
        }

        // 倒计时  
        function countDown(){
            second-=1;
            document.getElementById('count5s').innerText=second
        } 

        // 每隔一秒钟重新渲染一次秒数
        var countDown1=setInterval(countDown,1000)
        setInterval(function(){
            // 如果时间为0,关闭广告,清除定时器
            if(second==0){
                closeAds();
                clearInterval(countDown1);
            }
        },1000)
     </script>
</body>
</html>